# -*- coding: utf-8 -*-
# @Time    : 2024/12/24 21:19
# @Author  : Z.J. Zhang
# @Email   : zijingzhang@mail.ustc.edu.cn
# @File    : test.py
# @Software: PyCharm
import matplotlib
import numpy

matplotlib.use('tkagg')
import matplotlib.pyplot as plt
import scipy.constants as C

plt.ion()
z_i_ = numpy.linspace(-100e-3, 100e-3, int(1e5))
# plt.hist(numpy.random.rand(len(z_i)))
v_e = 0.5 * C.c  # 电子速度
f_0 = 3.5e9
Imax = 120
z_i = z_i_[numpy.sin(2 * numpy.pi / (v_e / f_0) * z_i_) + 1 > 2 * (numpy.random.rand(len(z_i_)))
           ]
n_L, z_bins = numpy.histogram(z_i, bins=len(z_i) // 200, density=True)
z_bins = z_bins[:-1]
q = Imax / (n_L * v_e).max()

plt.figure()
plt.hist(z_i, bins=len(z_i) // 200)

plt.figure()
plt.plot(z_i, numpy.zeros(z_i.shape), '.', alpha=0.01)



plt.figure()
plt.plot(z_bins, q* n_L* v_e)


